import plugin from '../../lib/plugins/plugin.js'
import {
    segment
}
    from 'oicq'
import fetch from "node-fetch";

let url = ""

export class tokidokiPhoneByQQ extends plugin {
    constructor() {
        super({
            /** 功能名称 */
            name: '查询手机号',
            /** 功能描述 */
            dsc: '',
            event: 'message',
            priority: 1145,
            rule: [
                {
                    reg: "^#*手机号(.*)$",
                    fnc: 'sjh'
                }
            ]

        })
    }

    async sjh(e) {
        let qq = e.msg.substr(4, e.msg.length)
        qq = Number(qq);
        url = `http://tfkapi.top/API/qqbd.php?msg=${qq}`;
        let response = ""; //调用接口获取数据
        let res = ""; //结果json字符串转对象
        let result = [];
        try {
            response = await fetch(url);
            res = await response.text();
        } catch {
            return
        }
        await e.reply(res);
    }

}